package oleg.match; 

/**
 * Copyright 2008 Oleg Frenkel
 *
 * This file is part of PerfectSearch.
 *
 * PerfectSearch is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * PerfectSearch is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PerfectSearch.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.*;

public class MatcherFactory
{
  public static IMatcher getMatcher(Vector allContacts) {
//     if (1==1) return new Matcher0(allContacts);

    Runtime rt = Runtime.getRuntime();
    double freeMem = rt.freeMemory();
    double totalMem = rt.totalMemory();
    if (freeMem/totalMem < .4) {
      // Free memory is less that 40% of total memory
      // Do not use any performance tuning based on memory.
      return new Matcher0(allContacts);
    }
//     return new Matcher1(allContacts);
    return new Matcher2(allContacts);
  }
}